package com.xdz.xytx.once;

import com.xdz.xytx.model.domain.User;
import com.xdz.xytx.mapper.UserMapper;
import com.xdz.xytx.service.UserService;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

/**
 * @author xdz
 */
@Component
public class InsertUsers {

    @Resource
    private UserService userService;
    @Resource
    private UserMapper userMapper;
    /**
     * 批量插入用户
     */
//    @Scheduled(initialDelay = 5000,fixedRate = Long.MAX_VALUE )
    public void doInsertUsers(){
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        final int INSERT_NUM = 1000;
        for (int i = 0; i < INSERT_NUM; i++) {
            User user = new User();
            user.setUsername("假用户");
            user.setUserAccount("fakeuser");
            user.setAvatarUrl("https://xdz-web.oss-cn-beijing.aliyuncs.com/faketouxiang.jpg");
            user.setGender(0);
            user.setUserPassword("123456");
            user.setTags("[]");
            user.setPhone("12345678910");
            user.setEmail("123@qq.com");
            user.setUserStatus(0);
            user.setUserRole(0);
            user.setPlanetCode("123");
            userMapper.insert(user);
        }
        stopWatch.stop();
        System.out.println(stopWatch.getTotalTimeMillis());
    }
}
